package org.real.guetshop.exception;

import lombok.extern.slf4j.Slf4j;
import org.real.guetshop.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /**
     * 处理商品数目大于库存异常
     * @param e
     * @return
     */
    @ExceptionHandler(StorageNotEnoughException.class)
    public Result handleStorageNotEnoughException (StorageNotEnoughException e) {
        log.info("进入了全局异常处理器...");
        return Result.error(e.getMessage());
    }
}
